<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 解构数组
        // 传统方式
        let a = 1, b = 2, c = 3
        console.log(a, b, c)
        // ES6 方式
        let [x, y, z] = [1, 2, 3]
        console.log(x, y, z)

        // 解构对象
        let user = { name: 'stt', age: 22 }
        // 传统方式
        let name_v = user.name
        let age_v = user.age
        console.log(name_v, age_v)
        // ES6 方式
        // 注意：解构的变量必须是对象中属性，要求名称一致
        let { name, age } = user
        console.log(name, age)
    </script>
</body>

</html>